import os
from dotenv import load_dotenv

load_dotenv()  # 加载.env文件


class Config:
    SECRET_KEY = os.getenv('SECRET_KEY', 'dev-key-123')  # 密钥
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    UPLOAD_FOLDER = os.path.join(os.path.dirname(__file__), 'static', 'uploads')
    MAX_CONTENT_LENGTH = 1024 * 1024 * 1024  # 16MB上传限制
    ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
    SESSION_TIMEOUT = 1800  
    SERVER_RESTART_ID_KEY = os.getenv('SERVER_RESTART_ID_KEY', 'dev-key-123')


class DevelopmentConfig(Config):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.getenv('DEV_DATABASE_URL', 'sqlite:///dev.db')


class ProductionConfig(Config):
    DEBUG = False
    SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL', 'sqlite:///prod.db')


config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}
